package com.atguigu.day20.work;

import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.TreeSet;

public class Work4 {
    public static void main(String[] args) {
        String[] nums = { "3", "4", "5", "6", "7", "8", "9", "10", "J", "Q", "K", "A", "2" };
        String[] colors = { "方片", "梅花", "红桃", "黑桃" };

        ArrayList<Integer> list = new ArrayList<Integer>();
        HashMap<Integer,String> map = new HashMap<>();
        int index = 1;
        for (String num : nums) {
            for (String color : colors) {
                map.put(index, color.concat(num));
                list.add(index);
                index++;
            }
        }
        map.put(index, "小王");
        list.add(index);
        index++;
        map.put(index, "大王");
        list.add(index);
        Collections.shuffle(list);
        TreeSet<Integer> left = new TreeSet<Integer>();
        TreeSet<Integer> right = new TreeSet<Integer>();
        TreeSet<Integer> me = new TreeSet<Integer>();
        TreeSet<Integer> up = new TreeSet<Integer>();
        TreeSet<Integer> lastCards = new TreeSet<Integer>();
        for (int i = 0; i < 13; i++) {
            right.add(list.remove(0));
            left.add(list.remove(0));
            me.add(list.remove(0));
            up.add(list.remove(0));
        }
        lastCards.addAll(list);

        lookPoker("左边玩家", left, map);
        lookPoker("右边玩家", right, map);
        lookPoker("上边玩家", up, map);
        lookPoker("我", me, map);
        lookPoker("底牌", lastCards, map);
    }

    public static void lookPoker(String name, TreeSet<Integer> ts, HashMap<Integer, String> map) {
        System.out.println(name + "的牌是:");
        for (Integer index : ts) {
            System.out.print(map.get(index) + " ");
        }
        System.out.println();
    }
}

